/*
 *  socket.h - socket input/output
 *  Copyright (c) 2005 Derek Ingrouville (dergro@users.sourceforge.net)
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef _SOCKET_H_
#define _SOCKET_H_

#include <glib.h>

typedef struct _Socket
{
    unsigned int sock_fd;
    char   *address;        /* Human readable IP address */
    unsigned int port;      /* Port this socket is connected to */
    gboolean connected;
} Socket;

Socket *socket_new ();
int socket_connect (Socket *socket, const char *addr, int port, gboolean nonblocking);
void socket_close (Socket *socket);

int socket_read (Socket *socket, char *dest_buf, unsigned int len);
int socket_write (Socket *socket, char *data, int len);

unsigned int socket_data_available (Socket *socket);

#endif /* _SOCKET_H_ */
